# 算法的接口模块


import os.path
import pickle
import sys

import pandas as pd

if(not os.path.exists("model.pkl")):
    import coreregressionalgrithm

with open("model.pkl", 'rb') as f:
    model = pickle.load(f)

numerical_features = ["Length", 'Diameter', 'Height','Whole weight',
                      'Shucked weight', 'Viscera weight', 'Shell weight']
categorical_feature = "Sex"
features = numerical_features + [categorical_feature]


def predict_age(x):
    x = pd.DataFrame([x], columns=features)
    age = model.predict(x)
    return round(age[0],2)

